/**
* @Title: grading_service.js
* @Description: TODO
* Copyright: Copyright (c) 2014 
 * Company:中国平安
*
* @Project HIMS-FWA
* @author EX-XIEQI001
* @date 2014年10月29日 下午2:24:03
* @version V1.0
*/
;
(function(){
	'use strict';
	
	var app = angular.module('fwa.mainApp');
	app.service('GradingService',['$http','Modal','BaseURL',
	                  function($http,Modal,baseUrl){
		var debug = true,
		debugUrls = {
				queryOrgGradingData: baseUrl+"/hcp/hcp/standardscore/query.do"
			},
			urls = {
			},
			serv = this;
		function getUrl(name) {
			if(debug) {
				return debugUrls[name];
			} else {
				return urls[name];
			}
		}
		
		var serv = this;
		serv.orgGradingData;      	// 医疗机构
		serv.orgType;
		serv.insuranceGradingData;  // 医保服务人员
		serv.insuranceType;
		serv.drugstoreGradingData;   // 药店
		serv.drugstoreType;
		
		serv.loading = false;
		
		
		//获取医疗机构评分标准
		this.queryOrgGradingData = function(){
			return $http({
				 method : 'GET',
				 cache : false,
		    	 url: baseUrl+"/hcp/hcp/standardscore/query.do",
		    	 params :{
		    		 temp:new Date()
		    	 }
			 });
		}
		
		//删除评分标准
		this.deleteGrading = function(id){
			return $http({
				 method : 'GET',
				 cache : false,
		    	 url: baseUrl+"/hcp/hcp/standardscore/deleteBySuperId.do",
		    	 params :{
		    		 temp:new Date(),
		    		 standardscoreid:id
		    	 }
			 });
		}

	
	}]).service('OrgGradingService',['$http','Modal','BaseURL',
	                  function($http,Modal,baseUrl){
		var debug = true,
		debugUrls = {
				queryOrgGradingData: baseUrl+"/hcp/hcp/standardscore/query.do",
				queryOrgGradingInfo: baseUrl+"/hcp/hcp/standardscore/queryDetail.do"
			},
			urls = {
			},
			serv = this;
		function getUrl(name) {
			if(debug) {
				return debugUrls[name];
			} else {
				return urls[name];
			}
		}
		
		//获取所有医疗机构评分标准
		this.queryOrgGradingData = function(){
			return $http({
				 method : 'GET',
				 cache : false,
		    	 url: baseUrl+"/hcp/hcp/standardscore/query.do",
		    	 params :{
		    		 temp:new Date()
		    	 }
			 });
		}
		
		//获取医疗机构评分标准
		this.queryOrgGradingInfo = function(id){
			return $http({
				 method : 'GET',
				 cache : false,
		    	 url: baseUrl+"/hcp/hcp/standardscore/queryDetail.do",
		    	 params :{
		    		 standardscoreid:id,
		    		 temp:new Date()
		    	 }
			 });
		}
		
		//新增修改医疗机构评分标准
		this.saveOrUpdateOrgGrading = function(gradingName,examineList){
			return $http.post(getUrl('saveOrUpdateOrgGrading'),{
					data:{
						tmp:Math.random(),
						gradingName:gradingName,
						examineList:examineList
					}
				});
		}

	
	}]).service('InsuranceGradingService',['$http','Modal','BaseURL',
	                  function($http,Modal,baseUrl){
		var debug = true,
			debugUrls = {
				queryInsuranceGradingData: baseUrl+"/hcp/hcp/standardscore/query.do",
				queryInsuranceGradingInfo: baseUrl+"/hcp/hcp/standardscore/queryDetail.do"
			},
			urls = {
			};
			function getUrl(name) {
				if(debug) {
					return debugUrls[name];
				} else {
					return urls[name];
				}
			}
		var serv = this;
		serv.loading = false;
		//获取所有医保服务人员评分标准
		this.queryInsuranceGradingData = function(scoreType){
			 $http({
				 method : 'GET',
				 cache : false,
		    	 url: baseUrl+"/hcp/hcp/standardscore/query.do",
		    	 params :{
		    		 temp:new Date(),
			 		scoreType:scoreType
		    	 }
			 }).success(function(response){
				serv.insuranceGradingDatas =  response.result.dtoList;
				serv.countNum =  response.result.upperValues;
			});
		}
		
		//获取医保服务人员评分标准
		this.queryInsuranceGradingInfo = function(id){
			return $http({
				 method : 'GET',
				 cache : false,
		    	 url: baseUrl+"/hcp/hcp/standardscore/queryDetail.do",
		    	 params :{
		    		 standardscoreid:id,
		    		 temp:new Date()
		    	 }
			 });
		}
		
		
		
		//新增修改医保服务人员评分标准
		this.saveOrUpdateInsuranceGrading = function(gradingName,insuranceList){
//			return $http.post(baseUrl + '/hcp/hcp/standardscore/save.do',{
//					data:{
//						tmp:Math.random(),
//					//	gradingName:gradingName,
//						insuranceList:insuranceList
//					}
//				});
		$http.post(baseUrl + '/hcp/hcp/standardscore/save.do',insuranceList).success(function(data) {
		});
		}

	
	}]).service('DrugstoreGradingService',['$http','Modal','BaseURL',
	                  function($http,Modal,baseUrl){
		var debug = true,
		debugUrls = {
				queryDrugstoreGradingData: baseUrl+"/hcp/hcp/standardscore/query.do",
				queryDrugstoreGradingInfo: baseUrl+"/hcp/hcp/standardscore/queryDetail.do"
//				saveOrUpdateDrugstoreGrading: baseUrl + 'mock/test.json'
			},
			urls = {
			},
			serv = this;
		function getUrl(name) {
			if(debug) {
				return debugUrls[name];
			} else {
				return urls[name];
			}
		}
		
		//获取所有药店评分标准
		this.queryDrugstoreGradingData = function(scoreType){
			return $http({
				 method : 'GET',
				 cache : false,
//		    	 url: getUrl("queryDrugstoreGradingData"),
				 url: baseUrl+"/hcp/hcp/standardscore/query.do",
		    	 params :{
		    		 scoreType:scoreType,
		    		 temp:new Date()
		    	 }
			 });
		}
		
		//获取药店评分标准
		this.queryDrugstoreGradingInfo = function(id){
			return $http({
				 method : 'GET',
				 cache : false,
//		    	 url: getUrl("queryDrugstoreGradingInfo"),
				 url: baseUrl+"/hcp/hcp/standardscore/queryDetail.do",
		    	 params :{
		    		 standardscoreid:id,
		    		 temp:new Date()
		    	 }
			 });
		}
		
		//新增修改药店评分标准
		this.saveOrUpdateDrugstoreGrading = function(gradingName,drugstoreList){
			return $http.post(getUrl('saveOrUpdateDrugstoreGrading'),{
				data:{
					tmp:Math.random(),
					gradingName:gradingName,
					drugstoreList:drugstoreList
				}
			});
		}
		
	}]);
	
})();